package com.my.study.common;

import com.my.study.bean.UserService1;
import com.my.study.springframework.bean.BeansException;
import com.my.study.springframework.bean.factory.config.BeanPostProcessor;

/**
 * @author: yidujun
 * @create: 2021/07/07 16:08
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("userService1".equals(beanName)) {
            ((UserService1) bean).setLocation("改为：北京");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
